<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>
        用户组列表
    </title>
    <meta content="webkit" name="renderer">
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1" name="viewport">
    <meta content="black" name="apple-mobile-web-app-status-bar-style">
    <meta content="yes" name="apple-mobile-web-app-capable">
    <meta content="telephone=no" name="format-detection">
    <link href="css/main.css" media="all" rel="stylesheet">
    <link href="css/bootstrap.css" rel="stylesheet"/>
</head>
<body>
<div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>用户组管理</cite></a>
              <a><cite>用户组列表</cite></a>
            </span>
    <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);"
       style="line-height:1.6em;margin-top:3px;float:right" title="刷新"><i class="layui-icon"
                                                                            style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">

    <xblock>
        <button class="layui-btn layui-btn-danger" onclick="delAll()">
            <i class="layui-icon">&#xe640;</i>批量删除
        </button>
        <button class="layui-btn" onclick="role_add('添加用户组','admingroupadd.html','900','500')"><i
                class="layui-icon">&#xe608;</i>添加
        </button>
        <span class="x-right" style="line-height:40px">共有数据：<span class="layui-badge">2</span> 条</span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <input name="" type="checkbox" value="">
            </th>
            <th>
                ID
            </th>
            <th>
                角色名
            </th>
            <th>
                拥有权限规则
            </th>
            <th>
                描述
            </th>
            <th>
                状态
            </th>
            <th>
                操作
            </th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                1
            </td>
            <td>
                超级管理员
            </td>
            <td>
                会员列表，问题列表
            </td>
            <td>
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-normal "
                                        onclick="role_status(this,'1',0)"> 启用 </span>
            </td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="role_edit('编辑','admingroupadd.html','1','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="role_del(this,'1')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        <tr>
            <td>
                <input name="" type="checkbox" value="1">
            </td>
            <td>
                2
            </td>
            <td>
                普通管理员
            </td>
            <td>
                会员列表，问题列表
            </td>
            <td>
            </td>
            <td class="td-status"><span class="layui-btn layui-btn-danger "
                                        onclick="role_status(this,'2',1)"> 禁用 </span></td>
            <td class="td-manage">
                <a class="ml-5" href="javascript:;" onclick="role_edit('编辑','admingroupadd.html','2','','510')"
                   style="text-decoration:none" title="编辑">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a href="javascript:;" onclick="role_del(this,'2')" style="text-decoration:none"
                   title="删除">
                    <i class="layui-icon">&#xe640;</i>
                </a>
            </td>
        </tr>
        </tbody>
    </table>

    <div id="page">
    </div>
</div>
<script charset="utf-8" src="lib/layui/layui.js"></script>
<script charset="utf-8" src="js/x-layui.js"></script>
<script>
    layui.use(['laydate', 'element', 'laypage', 'layer'], function () {
        $ = layui.jquery;//jquery
        laydate = layui.laydate;//日期插件
        lement = layui.element();//面包导航
        laypage = layui.laypage;//分页
        layer = layui.layer;//弹出层

        //以上模块根据需要引入
    });

    //批量删除提交
    function delAll() {
        layer.confirm('确认要删除吗？', function (index) {
            //捉到所有被选中的，发异步进行删除
            layer.msg('删除成功', {icon: 1});
        });
    }

    /*添加*/
    function role_add(title, url, w, h) {
        x_admin_show(title, url, w, h);
    }


    //编辑
    function role_edit(title, url, id, w, h) {
        url = url + '?id=' + id;
        x_admin_show(title, url, w, h);
    }

    /*删除*/
    function role_del(obj, id) {
        layer.confirm('确认要删除吗？', {icon: 3, title: '提示'}, function (index) {
            $.ajax({
                type: "post",
                url: "xxx",
                data: {id: id},
                dataType: "json",
                async: true,
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg(data.info, {icon: 6, time: 1000});
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                        return false;
                    } else {
                        layer.msg(data.info, {icon: 5, time: 1000});
                        return false;
                    }
                }
            });
        });
    }

    /**
     * 用户组状态修改
     */
    function role_status(obj, id, e) {
        layer.confirm(e == 1 ? '你确定要启用吗？' : '你确定要禁用吗？', {icon: 3, title: '提示'}, function (index) {
            $.ajax({
                type: "post",
                url: "xxx",
                data: {id: id, status: e},
                dataType: "json",
                success: function (data) {
                    if (data.status == 1) {
                        //发异步把用户状态进行更改
                        $(obj).attr("class", "layui-btn layui-btn-danger ");
                        $(obj).text("隐藏");
                        $(obj).remove();
                        layer.msg(data.info, {icon: 6, time: 1000});
                        setTimeout(function () {
                            window.location.reload();
                        }, 1000);
                        return false;
                    } else {
                        //发异步把用户状态进行更改
                        $(obj).attr("class", "layui-btn layui-btn-normal ");
                        $(obj).text("显示");
                        $(obj).remove();
                        layer.msg(data.info, {icon: 5, time: 1000});
                        return false;
                    }
                }
            });

        });
    }
</script>

</body>
</html>